USE [LSNU_SBGL]
GO
/****** Object:  UserDefinedFunction [dbo].[funSelectSBBHandSBZT]    Script Date: 2018/12/27 9:25:10 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER function [dbo].[funSelectSBBHandSBZT]
(
	@ZGH Varchar(8),
	@condStr Varchar(200)
)
returns table as
return(
	Select Distinct JBXX_SB.SBBH,JBXX_SB.SBZTDM 
	From JBXX_SBSY Join JBXX_SB On JBXX_SBSY.SBBH=JBXX_SB.SBBH 
				   Join DM_ZCLB On JBXX_SB.ZCLBDM = DM_ZCLB.ZCLBDM 
				   Join DM_CWLB On JBXX_SB.CWLBDM = DM_CWLB.CWLBDM 
				   Join DM_SBLB On JBXX_SB.SBLBDM = DM_SBLB.SBLBDM 
				   Join DM_SBZT On JBXX_SB.SBZTDM = DM_SBZT.SBZTDM 
	Where (ZGH Like @ZGH+'%') And (JBXX_SB.SBBH Like @condStr+'%' Or SBLY like @condStr+'%' Or ZCLB Like @condStr+'%' Or CWLB Like @condStr+'%' Or SBLB Like @condStr+'%' Or SBZT Like @condStr+'%')
)
